<?php

namespace App\Modules\Apicrzs\Entities;

use App\Models\Model;

class ApparatusModel extends Model
{

    protected $table='apparatuses';

    /**
     * @return HasOne
     */
    public function community(): HasOne
    {
        return $this->hasOne(CommunityModel::class, 'community_id', 'id');
    }
    /**
     * @return HasOne
     */
    public function community_info()
    {
        return $this->belongsTo(CommunityModel::class, 'community_id', 'id');
    }

    /**
     * @return HasOne
     */
    public function user(): HasOne
    {
        return $this->hasOne(UsersModel::class, 'id', 'user_id');
    }
    public function getSelectListsById($ids){
        return $this->with(['community'])->whereIn('id',$ids)->orderBy($this->getKeyName(), 'ASC')
            ->get(['id','title','community_id','address'])->toArray();
    }
}
